<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: ActionView::Helpers::DebugHelper</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">ActionView::Helpers::DebugHelper</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/rails/actionpack/lib/action_view/helpers/debug_helper_rb.html">
                vendor/rails/actionpack/lib/action_view/helpers/debug_helper.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Provides a set of methods for making it easier to <a
href="DebugHelper.html#M002014">debug</a> <a
href="../../Rails.html">Rails</a> objects.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M002014">debug</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M002014" class="method-detail">
        <a name="M002014"></a>

        <div class="method-heading">
          <a href="#M002014" class="method-signature">
          <span class="method-name">debug</span><span class="method-args">(object)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a YAML representation of <tt>object</tt> wrapped with &lt;pre&gt;
and &lt;/pre&gt;. If the object cannot be converted to YAML using
<tt>to_yaml</tt>, <tt>inspect</tt> will be called instead. Useful for
inspecting an object at the time of rendering.
</p>
<h4>Example</h4>
<pre>
  @user = User.new({ :username =&gt; 'testing', :password =&gt; 'xyz', :age =&gt; 42}) %&gt;
  debug(@user)
  # =&gt;
  &lt;pre class='debug_dump'&gt;--- !ruby/object:User
  attributes:
  &amp;nbsp; updated_at:
  &amp;nbsp; username: testing

  &amp;nbsp; age: 42
  &amp;nbsp; password: xyz
  &amp;nbsp; created_at:
  attributes_cache: {}

  new_record: true
  &lt;/pre&gt;
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M002014-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M002014-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/actionpack/lib/action_view/helpers/debug_helper.rb, line 27</span>
27:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">debug</span>(<span class="ruby-identifier">object</span>)
28:         <span class="ruby-keyword kw">begin</span>
29:           <span class="ruby-constant">Marshal</span><span class="ruby-operator">::</span><span class="ruby-identifier">dump</span>(<span class="ruby-identifier">object</span>)
30:           <span class="ruby-node">&quot;&lt;pre class='debug_dump'&gt;#{h(object.to_yaml).gsub(&quot;  &quot;, &quot;&amp;nbsp; &quot;)}&lt;/pre&gt;&quot;</span>
31:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>  <span class="ruby-comment cmt"># errors from Marshal or YAML</span>
32:           <span class="ruby-comment cmt"># Object couldn't be dumped, perhaps because of singleton methods -- this is the fallback</span>
33:           <span class="ruby-node">&quot;&lt;code class='debug_dump'&gt;#{h(object.inspect)}&lt;/code&gt;&quot;</span>
34:         <span class="ruby-keyword kw">end</span>
35:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>